﻿using ManaSky.Entity;
using ManaSky.IService;
using ManaSky.Common.Helpers;
using ManaSky.SSO.Interface;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace ManaSky.Api.Controllers
{
    [Route("api/[controller]")]
    public class TestController : BaseController
    {
        private readonly ISysUsersService _sysUsersService;

        public TestController(IConfiguration configuration,IAuth auth, ISysUsersService sysUsersService) : base(configuration,auth)
        {
            _sysUsersService = sysUsersService;
        }

        [HttpPost,Route("GetTest"),Authorize]
        public async Task<IActionResult> GetTest()
        {
            var user =  _auth.GetCurrentUser();
            var result = await _sysUsersService.GetList();
            result.ReturnData = user;
            return new JsonResult(result.ToRequest());
        }
        [HttpPost, Route("Save"), AllowAnonymous]
        public async Task<IActionResult> Save(sys_user sys_Users)
        {
            await _sysUsersService.Save(sys_Users);
            return new JsonResult("OK");
        }
        [HttpPost, Route("Update")]
        public IActionResult Update()
        {
            _sysUsersService.Update(null);
            return new JsonResult("OK");
        }
        [HttpPost, Route("Delete")]
        public async Task<IActionResult> Delete()
        {
            await _sysUsersService.Delete(null);
            return new JsonResult("OK");
        }
    }
}
